package com.ems.mapper;

import com.ems.entity.MenuEntity;
import com.ems.entity.RoleMenuEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * <p>
 * 角色权限表 Mapper 接口
 * </p>
 *
 * @author WuZH
 * @since 2023-10-24
 */
@Mapper
public interface RoleMenuMapper extends BaseMapper<RoleMenuEntity> {

    @Select (value = "select mi.id,mi.name,mi.note,mi.type,mi.sort,mi.parentId from role_menu_info rmi left join menu_info mi on rmi.menuId=mi.id where rmi.roleId=#{roleMenuEntity.roleId}")
    List<MenuEntity> queryList ( @Param ("roleMenuEntity") RoleMenuEntity roleMenuEntity);

    @Insert (value = "INSERT INTO role_menu_info(id,roleId,menuId,createTime) VALUE(#{roleMenuEntity.id},#{roleMenuEntity.roleId},#{roleMenuEntity.menuId},#{roleMenuEntity.createTime})")
    Integer saveSingle (@Param ("roleMenuEntity") RoleMenuEntity roleMenuEntity);

    @Delete ( value = "DELETE FROM role_menu_info WHERE roleId=#{roleMenuEntity.roleId} ")
    void deleteSingle(@Param ("roleMenuEntity") RoleMenuEntity roleMenuEntity);
}
